package com.example.safeassistan.home.adapter;

import android.widget.ImageView;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.example.safeassistan.R;
import com.example.safeassistan.risk.model.RiskDetailHiddenDanger;

import java.util.List;

public class RiskDetailHiddenFragmentAdapter extends BaseQuickAdapter<RiskDetailHiddenDanger.ResultDTO,BaseViewHolder> {
    public RiskDetailHiddenFragmentAdapter(@Nullable List<RiskDetailHiddenDanger.ResultDTO> data) {
        super(R.layout.item_riskdetail_hiddendanger, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, RiskDetailHiddenDanger.ResultDTO item) {
        ImageView ivImg=helper.getView(R.id.ivImg);
        TextView tvDot=helper.getView(R.id.tvDot);
        TextView tvStatus1=helper.getView(R.id.tvStatus1);
        Glide.with(mContext).load(item.getHdangerImg()).placeholder(R.mipmap.default_image).into(ivImg);
        helper.setText(R.id.tvHiddendDangerName,item.getHdangerTitle()+"");
        helper.setText(R.id.tvOwer,item.getCreateBy()+"");
        helper.setText(R.id.tvReform,item.getAllottedTime()+"");
        switch (item.getHdangerLevel()+""){
            case "1":
                helper.setText(R.id.tvHiddendDangerLevel,"一般");
                tvDot.setBackgroundResource(R.drawable.orange_circle);
                break;
            case "3":
                helper.setText(R.id.tvHiddendDangerLevel,"重大");
                tvDot.setBackgroundResource(R.drawable.red_circle);
                break;
        }

        switch (item.getDisposeStatus()+""){
            case "1":
                //待提交
                tvStatus1.setText("待提交");
                tvStatus1.setBackgroundResource(R.drawable.leftcorner_purple_bg);
                break;
            case "2":
                //待评审
                tvStatus1.setText("待评审");
                tvStatus1.setBackgroundResource(R.drawable.leftcorner_green_bg);
                break;
            case "3":
                //待整改
                if (item.getRectSubmit()==0){
                    tvStatus1.setText("待整改");
                    tvStatus1.setBackgroundResource(R.drawable.leftcorner_blue_bg);
                }else {
                    tvStatus1.setText("重新整改");
                    tvStatus1.setBackgroundResource(R.drawable.leftcorner_blue_bg);
                }
                break;
            case "4":
                // 待验收
                tvStatus1.setText("待验收");
                tvStatus1.setBackgroundResource(R.drawable.leftcorner_red_bg);
                break;
            case "5":
                //已验收
                tvStatus1.setText("已验收");
                tvStatus1.setBackgroundResource(R.drawable.leftcorner_orange_bg);
                break;
            case "6":
                //已评审
                tvStatus1.setText("已撤销");
                tvStatus1.setBackgroundResource(R.drawable.leftcorner_gray_bg);
                break;
        }
    }
}
